<template>
  <div class="p-d">
    <div class="b-f p-d">
      <SearchComp :searchForm="searchForm" :searchData="queryString" :searchAction="searchAction"></SearchComp>
      <div class="btnStyle flex-between p-t">
        <ButtonComp :buttonData="buttonData" />
      </div>
      <div class="m-t">
        <TableCompEle class="m-t" ref="multipleTable" height="50vh" :tableData="tableData" :tableConfig="tableConfig" :tableAction="tableAction"
          :isSelect="true" :isIndex="true" :isShowPage="true" :queryParams="queryParams" @getPagination="getList"
          @handleSelectionChange="handleSelectionChange"></TableCompEle>
      </div>
    </div>
    <AddComp ref="addRef" @close="getList" />
  </div>
</template>

<script>
import AddComp from './common/add.vue'
export default {
  components: { AddComp },
  data() {
    return {
      activeName: 'all',
      buttonData: [
        {
          kind: 'button',
          label: '新增',
          plain: false,
          size: 'small',
          type: 'primary',
          click: () => {
            this.$refs.addRef.show({
              title: '新建地方共享资源使用情况',
              isLook: 'add',
            })
          }
        },
        {
          kind: 'button',
          label: '一键导出',
          plain: false,
          size: 'small',
          type: 'warning',
          click: () => { }
        },
        {
          kind: 'button',
          label: '一键导入',
          plain: false,
          size: 'small',
          type: 'warning',
          click: () => { }
        },
        {
          kind: 'button',
          label: '批量删除',
          plain: false,
          size: 'small',
          type: 'danger',
          click: () => {
            // if (this.multipleSelection.length == 0) {
            //   this.$message({
            //     type: 'warning',
            //     message: '请选择要删除的数据'
            //   })
            //   return
            // }
            const ids = []
            // this.multipleSelection.forEach(items => {
            //   ids.push(items.id)
            // })
            this.deleteFun(ids)
          }
        }
      ],
      queryParams: {
        total: 0,
        currentPage: 1,
        pageSize: 10
      },
      tableData: [
        {
          title: 'xxxxx',
          content: 'xxxxx',
          name: 'xxxxx',
          createdTime: 'xxxxx'
        }
      ],
      tableConfig: [
        {
          prop: 'title',
          label: '服务合同（协议）编号'
        },
        {
          prop: 'title',
          label: '服务评价'
        },
        {
          prop: 'name',
          label: '评价意见'
        },
        {
          prop: 'createdTime',
          label: '评价时间'
        },
        {
          prop: 'createdTime',
          label: '评价人'
        },
      ],
      tableAction: {
        align: () => 'center',
        width: () => String(170),
        operations: [
          {
            label: '查看',
            isLink: true,
            type: 'primary',
            method: row => {
              this.$refs.addRef.show({
                title: '查看地方共享资源使用情况',
                isLook: 'look',
                data: row
              })
            }
          },
          {
            label: '修改',
            isLink: true,
            type: 'primary',
            method: row => {
              this.$refs.addRef.show({
                title: '修改地方共享资源使用情况',
                isLook: 'edit',
                data: row
              })
            }
          },
          {
            label: '删除',
            isLink: true,
            type: 'danger',
            method: row => {
              this.deleteFun([row.id])
            }
          }
        ]
      },
      queryString: {
        title: '',
        id: ''
      },
      searchForm: {
        changeMethod: () => {
          this.queryParams.currentPage = 1
          this.getList()
        },
        formData: [
          {
            type: 'Input',
            label: '服务合同（协议）编号',
            prop: 'id',
            clearable: true,
            icon: 'el-icon-search',
            placeholder: '请输入'
          },
          {
            type: 'Input',
            label: '服务评价',
            prop: 'title',
            clearable: true,
            icon: 'el-icon-search',
            placeholder: '请输入'
          },
        ]
      },
      searchAction: [
        {
          label: '查询',
          type: 'primary',
          handle: () => {
            this.queryParams.currentPage = 1
            this.$refs.multipleTable.clearSelection()
            this.getList()
          }
        },
        {
          label: '重置',
          type: 'primary',
          plain: true,
          handle: () => {
            this.queryString = {
              title: '',
              id: ''
            }
            this.queryParams.currentPage = 1
            this.getList()
          }
        }
      ]
    }
  },
  methods: {
    getList() { },
    handleSelectionChange() { },
    deleteFun(ids) {
      console.log('%c [ ids ]-216', 'font-size:13px; background:pink; color:#bf2c9f;', ids)
      this.$confirm(`确定要删除吗？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          })
        })
    },
  },
}
</script>

<style lang="less" scoped>
</style>